package com.zxb.user.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/nacos")
@Slf4j
public class NacosConfigController implements EnvironmentAware {

    @Value("${common.name}")
    private String name;

    @Value("${common.age}")
    private String age;

    @Value("${money}")
    private String money;

    private Environment environment;


    @GetMapping("/getConfig")
    public String config(){
        return name + ":" +age + ":" + money;
    }

    @GetMapping("/getConfig2")
    public String config2(){
        return environment.getProperty("common.name") + ":" +environment.getProperty("common.age")+ ":" +environment.getProperty("money");
    }

    @Override
    public void setEnvironment(Environment environment) {
        this.environment = environment;
    }
}
